package cn.z2huo.productcenter.productcatalog.app.dao.impl.risk;

import cn.z2huo.core.enums.YesNoEnum;
import cn.z2huo.productcenter.mapper.risk.RiskMapper;
import cn.z2huo.productcenter.model.dataobject.risk.RiskDO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *
 * @author z2huo
 */
@Repository
@RequiredArgsConstructor
public class RiskDAOImpl {

    private final RiskMapper riskMapper;

    /**
     * <p>获取所有有效的产品代码
     * @return  产品代码列表
     */
    public List<String> listValidRisk() {
        LambdaQueryWrapper<RiskDO> queryWrapper = Wrappers.lambdaQuery(RiskDO.class);
        queryWrapper.select(RiskDO::getRiskCode)
                .eq(RiskDO::getAvailableFlag, YesNoEnum.YES.getValue());
        List<String> riskCodeList = riskMapper.selectObjs(queryWrapper);
        return riskCodeList;
    }
}

